/******* 公共JS ********/

//获取首页广告
function aj_get_banner(placeid, banner) {
	$.ajax({
		type:"POST",
		url:"/ajax/get_banner/",
		data:"placeid="+placeid,
		success:function(data){
			$("#"+banner).html(data);
		}
	});
}

//AJAX验证相关
//=============================================================
//帐户相关
//Ajax验证注册表单
function aj_check_register(value, type, obj) {
	$.ajax({
		type:"POST",
		url:"/ajax/check_register/",
		data:"value="+value+"&type="+type,
		success:function(data){
			if(data != "") {
				show_validator_msg(obj, data);
			} else {
				show_validator_msg(obj, '');
			}
		}
	});
}

//JS验证表单相关
//=============================================================
//检测帐户注册表单
function check_register_form(form) {
	
	var empty_email = empty_username = empty_password = false;
	//验证字段
	empty_email = check_empty_field(form.email, "email", "");
	empty_username = check_empty_field(form.username, "username", "");
	empty_password = check_empty_field(form.password, "password", "");
	//empty_yzcode = check_empty_field(form.yzcode, "yzcode", "");
	if(empty_email || empty_username || empty_password) {
		return false;	
	}	
}

//检测首页帐户登陆表单
function check_homelogin_form(form) {
	//验证字段
	if($("#loginemail").val() == "") {
		$("#login_ts").html("请输入Email");
		$("#loginemail").focus();
		return false;
	}
	if($("#loginpassword").val() == "") {
		$("#login_ts").html("请输入密码");
		$("#loginpassword").focus();
		return false;
	}
}

//检测好站帐户登陆表单
function check_sitelogin_form() {
	//验证字段
	if($("#loginemail").val() == "") {
		$("#ts").html("请输入Email");
		$("#loginemail").focus();
		return false;
	}
	if($("#loginpassword").val() == "") {
		$("#ts").html("请输入密码");
		$("#loginpassword").focus();
		return false;
	}
	var email = $("#loginemail").val();
	var password = $("#loginpassword").val();
	$.ajax({
		type:"POST",
		url:"/ajax/check_login/",
		data:"email="+email+"&password="+password,
		success:function(data){
			if(data == "0") {
				$("#ts").html("Email或密码错误");
				$("#loginemail").focus();
			} else {
				$("#loginform").submit();
			}
		}
	});
}

$(document).ready(function(){
    $("#loginform").keydown(function(event){
      if(event.keyCode==13){
	      	check_sitelogin_form();
        }
    });
});

//检测帐户登陆表单
function check_login_form(form) {
	var empty_email = empty_password = false;
	//验证字段
	empty_email = check_empty_field(form.loginemail, "loginemail", "");
	empty_password = check_empty_field(form.loginpassword, "loginpassword", "");
	if(empty_email || empty_password) {
		return false;	
	}
}

//检测帐户忘记密码表单
function check_forget_form(form) {
	var empty_email = empty_yzcode = false;
	//验证字段
	empty_email = check_empty_field(form.email, "email", "邮件地址");
	empty_yzcode = check_empty_field(form.yzcode, "yzcode", "验证码");
	if(empty_email || empty_yzcode) {
		return false;	
	}
}

//=============================================================
